@extends('mobile.layout1')
@section('content')
    <body>
    <div class="view-container mgn55">
        <div class="view-inner">
            <section class="mod-goods-list">
                <div class="filter">
                    <ul>
                        <li data-column="goods_sort"     class="js-column @if($type==null) active @endif"><a href="{{route('good.all',['type'=>null])}}">默认</a> </li>
                        <li data-column="csale" class="js-column @if($type=='stock') active @endif"><a href="{{route('good.all',['type'=>'stock'])}}"> 库存量</a><i class="if if-sort"></i></li>
                        <li data-column="created_at" class="js-column @if($type=='created_at') active @endif"><a href="{{route('good.all',['type'=>'created_at'])}}">新品</a><i class="if if-sort"></i></li>
                        <li data-column="price" class="js-column @if($type=='cost_price') active @endif"><a href="{{route('good.all',['type'=>'cost_price'])}}">价格</a><i class="if if-sort"></i></li>
                        <li class="show-type-btn js-show-type"><i class="if if-list"></i></li>
                    </ul>
                </div>
                <ul class="goods-list js-goods-list clearfix">
                    @if(!$goods->isEmpty())
                    @foreach($goods as $v)
                    <li class="clearfix">
                        <a href="{{route('goods.show',['id'=>$v->id])}}">
                            <div class="goods-image">
                                <img class="lazy" data-original="{{$v->goods_thumbnail}}"  style="display: inline;">
                            </div>
                            <div class="goods-info">
                                <p class="goods-title">{{$v->goods_name}} </p>
                                @if(Auth::user()->can('charge',$v))
                                    <p class="goods-price"> ￥{{$v->repeat_price}}<del>￥{{$v->cost_price}}</del></p>
                                    @else
                                    <p class="goods-price"> ￥{{$v->cost_price}}</p>
                                @endif
                                <p class="goods-sale">库存：{{$v->stock}}件</p>
                                <div class="goods-buy if if-cart-add js-open-cart" cart-gid="{{$v->id}}" cart-title="{{$v->goods_name}}" cart-num="{{$v->stock}}" cart-img="{{$v->goods_thumbnail}}" cart-price="@if(Auth::user()->is_recharge==1) {{$v->repeat_price}} @else {{$v->cost_price}} @endif">购买</div>
                            </div>
                        </a>
                    </li>
                    @endforeach
                    @endif

                </ul>
            </section>
        </div>
    </div>
    <div class="footer-nav">
        <ul class="nav-items">
            <li class="">
                <a href="/">
                    <div class="footer-icon1"></div>
                    <span>首页</span>
                </a>
            </li>
            <li class="active">
                <a href="/goods">
                    <div class="footer-icon2"></div>
                    <span>全部商品</span>
                </a>
            </li>
            <li>
                <a href="/user">
                    <div class="footer-icon3"></div>
                    <span>会员中心</span>
                </a>
            </li>
        </ul>
    </div>
    <div class="popup popup-sku remove-on-close modal-in">
        <div class="goods-summary">
            <div class="thumb">
                <img id="main-img" class="wx-preview-image" >
            </div>
            <div class="detail">
                <p class="title"></p>
                <div class="price-scope cart-price-num">
                    <i class="price-currency">￥</i>
                    <span class="price-integer"></span>
                </div>
                <div class="x_stock stock"> 库存：<span class="cart-stock-num">291</span>件 </div>
            </div>
            <div class="close-popup if if-close" data-popup=".popup-sku"></div>
        </div>
        <div class="popup-sku-content" style="max-height: 567px;"> <!-- 商品规格 -->
            <div class="quantity-control clearfix">
                <label>购买数量</label>
                <div class="quantity">
                    <button class="minus cart-num-minus1 disabled" style="padding: 0;text-align: center;"><i class="if if-minis"></i></button>
                    <input type="tel" class="cart-num1" name="cart-num" value="1">
                    <input type="hidden" id="goods_id" class="goods_id" >
                    <button class="plus cart-num-plus1" style="padding: 0;text-align: center;"><i class="if if-plus"></i></button>
                </div>
            </div>
            <div class="popup-options cart-btn-two clearfix">
                <button type="button" class="btn btn-block btn-cart cart-submit-btn" onclick="cartAdd()">加入购物车</button>
                <button type="button" class="btn btn-block btn-buy cart-buy-btn" onclick="cartsettlement()">立即购买</button>
            </div>
        </div>
    </div>
    <div class="popup-overlay"></div>
    </body>
    @endsection
@section('js')
<script>
    $(function() {

        $("img.lazy").lazyload({effect: "fadeIn"});

    });
    function cartAdd(){
        var good_id=$("#goods_id").val();
        var num=$(".cart-num1").val();
        addCart(good_id,num);
    }
    function cartsettlement(){
        var good_id=$("#goods_id").val();
        var num=$(".cart-num1").val();

        fastSettlement(good_id,num);
    }
</script>
    @endsection